<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统- 用户管理</title>
<link href="<%=basePath%>/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath%>/js/jquery/jquery-1.7.1.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/main.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/datepicker/WdatePicker.js"></script>
</head>
<body>
<div style="padding: 2px;">
	<c:set var="actionUrl" value="${pageContext.request.contextPath}/saveUser.do"/>
	<c:if test="${not empty userBean.userId}">
		<c:set var="actionUrl" value="${pageContext.request.contextPath}/updateUser.do"/>
	</c:if>
	<form id="userEditForm"  name="userEditForm" action="${actionUrl}" method="post" target="consoleFrame" >
	<table width="500" border="1" cellpadding="1" cellspacing="0" bordercolor="#eeeeee" align="center">
		<input name="userForm.userId" type="hidden" value="${userBean.userId}"/>
		<tr>
			<td width="25%">用户类型：</td>
			<td width="75%">
				<select name="userForm.userType" style="width:170px" onchange="userTypeOnChange(this);">
					<option value="USER_TYPE_SYSTEM">系统</option>
					<option value="USER_TYPE_TRAVELAGENCY">旅行社</option>
					<option value="USER_TYPE_SIGHT">景区</option>
				</select>
			</td>
		</tr>
		<tr id="isAdminTr">
			<td>是否管理员：</td>
			<td>
				<input type="radio" name="userForm.isAdmin" value="true" />是
				<input type="radio" name="userForm.isAdmin" value="false" />否
			</td>
		</tr>
		<tr>
			<td>标题：</td>
			<td>
				<input name="userForm.title" type="text" class="input1" id="userForm.title" value="${userBean.title}" size="30" verify="NotNull"/>
			</td>
		</tr>		
		<tr>
			<td>登录名：</td>
			<td>
				<input name="userForm.userName" type="text" class="input1" id="userForm.userName" value="${userBean.userName}" size="30" verify="NotNull"/>
			</td>
		</tr>
		<tr>
			<td>登录密码：</td>
			<td>
				<input name="userForm.passWord" type="password" class="input1" id="userForm.passWord" value="${userBean.passWord}" size="30" verify="NotNull"/>
			</td>
		</tr>
		<tr>
			<td>姓名：</td>
			<td>
				<input name="userForm.realName" type="text" class="input1" id="userForm.realName" value="${userBean.realName}" size="30" verify="NotNull"/>
			</td>
		</tr>
		<tr>
			<td>电话：</td>
			<td>
				<input name="userForm.phone" type="text" class="input1" id="userForm.phone" value="${userBean.phone}" size="30" verify="NotNull"/>
			</td>
		</tr>
		<tr>
			<td>是否启用：</td>
			<td>
				<input type="radio" name="userForm.isLock" value="false" checked="checked" />是
				<input type="radio" name="userForm.isLock" value="true" />否
			</td>
		</tr>		
		<tr align="center">
			<td colspan="2">
			 <input type="submit" value="保存"/>
			 &nbsp;
			 &nbsp;
			 &nbsp;
			 <input type='button' onclick="parent.closeWin();" value="关闭"/>
			</td>
		</tr>
	</table>

	</form>
	</div>
	</body>
</html>
<script type="text/javascript">
	$(function(){
		$("select[name='userForm.userType']").val("${userBean.userType}");
		$("input[name='userForm.isAdmin'][value='${userBean.isAdmin}']:radio").attr("checked",true);
		$("input[name='userForm.isLock'][value='${userBean.isLock}']:radio").attr("checked",true);
		$("select[name='userForm.userType']").change();
	});
	function userTypeOnChange(thisObj){
		if($(thisObj).val()=="USER_TYPE_SYSTEM"){
			$("#isAdminTr").show();
		}else{
			$("#isAdminTr").hide();
		}
	}
</script>